#include<iostream>
#include"Socket.hpp"
#include"TcpServer.hpp"
#include"Protocol.hpp"
#include<memory>

void HandlerRequest(Net_Work::Socket* sockp)
{
    // std::cout<<"接收成功"<<std::endl;
    while(true)
    {
        struct Request req;
        recv(sockp->GetSocket(),&req,sizeof(req),0);
        req.Print();
    }
}
int main(int argc,char* argv[])
{
    if(argc!=2)
    {
        std::cout<<"Usage : "<<argv[0]<<" localport "<<std::endl;
        return 0;
    }
    uint16_t localport=std::stoi(argv[1]);
    std::unique_ptr<TcpServer> tsvr(new TcpServer(localport,HandlerRequest));
    tsvr->Loop();
    return 0;
}